# !/usr/bin/env python
# -*- coding: utf-8 -*-


import databases

from app.core.config import DATABASE_URL_WXMAP
from .redis_utils import red

if not DATABASE_URL_WXMAP:
    raise ValueError("Can not connect to database, please check file '.env' or system env.")

# gipp 数据库
database_wxmap = databases.Database(DATABASE_URL_WXMAP)


async def startup():
    await database_wxmap.connect()
    await red.connect()


async def shutdown():
    await database_wxmap.disconnect()
    await red.close()

